package com.eveinfo.display;

import java.text.DecimalFormat;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;

import com.eveinfo.EveInfo;
import com.eveinfo.R;
import com.eveinfo.api.character.sheet.ApiSheet;
import com.eveinfo.api.character.sheet.CharismaBonus;
import com.eveinfo.api.character.sheet.IntelligenceBonus;
import com.eveinfo.api.character.sheet.MemoryBonus;
import com.eveinfo.api.character.sheet.PerceptionBonus;
import com.eveinfo.api.character.sheet.WillpowerBonus;
import com.eveinfo.tools.Tools;

public class AttributesView extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.attributes);

		final int characterID = getIntent().getIntExtra("characterID", 0);
		ApiSheet sheet = EveInfo.getData().getCharacterSheet(characterID);
		if (sheet == null) {
			// TODO
			finish();
			return;
		}

		DecimalFormat format = new DecimalFormat();
		format.setMaximumFractionDigits(2);

		TextView charisma = (TextView) findViewById(R.id.TVAttributesCharisma);
		charisma.setText("" + format.format(Tools.getAttributValue(sheet, Tools.Attribut.charisma)));

		TextView intelligence = (TextView) findViewById(R.id.TVAttributesIntelligence);
		intelligence.setText("" + format.format(Tools.getAttributValue(sheet, Tools.Attribut.intelligence)));

		TextView memory = (TextView) findViewById(R.id.TVAttributesMemory);
		memory.setText("" + format.format(Tools.getAttributValue(sheet, Tools.Attribut.memory)));

		TextView perception = (TextView) findViewById(R.id.TVAttributesPerception);
		perception.setText("" + format.format(Tools.getAttributValue(sheet, Tools.Attribut.perception)));

		TextView willpower = (TextView) findViewById(R.id.TVAttributesWillpower);
		willpower.setText("" + format.format(Tools.getAttributValue(sheet, Tools.Attribut.willpower)));

		TextView charismaIA = (TextView) findViewById(R.id.TVAttributesCharismaIA);
		charismaIA.setText("Charisma +" + sheet.getAttributeBonus(CharismaBonus.class));

		TextView intelligenceIA = (TextView) findViewById(R.id.TVAttributesIntelligenceIA);
		intelligenceIA.setText("Intelligence +" + sheet.getAttributeBonus(IntelligenceBonus.class));

		TextView memoryIA = (TextView) findViewById(R.id.TVAttributesMemoryIA);
		memoryIA.setText("Memory +" + sheet.getAttributeBonus(MemoryBonus.class));

		TextView perceptionIA = (TextView) findViewById(R.id.TVAttributesPerceptionIA);
		perceptionIA.setText("Perception +" + sheet.getAttributeBonus(PerceptionBonus.class));

		TextView willpowerIA = (TextView) findViewById(R.id.TVAttributesWillpowerIA);
		willpowerIA.setText("Willpower +" + sheet.getAttributeBonus(WillpowerBonus.class));

		TextView charismaIN = (TextView) findViewById(R.id.TVAttributesCharismaIN);
		charismaIN.setText(sheet.getNameBonus(CharismaBonus.class));

		TextView intelligenceIN = (TextView) findViewById(R.id.TVAttributesIntelligenceIN);
		intelligenceIN.setText(sheet.getNameBonus(IntelligenceBonus.class));

		TextView memoryIN = (TextView) findViewById(R.id.TVAttributesMemoryIN);
		memoryIN.setText(sheet.getNameBonus(MemoryBonus.class));

		TextView perceptionIN = (TextView) findViewById(R.id.TVAttributesPerceptionIN);
		perceptionIN.setText(sheet.getNameBonus(PerceptionBonus.class));

		TextView willpowerIN = (TextView) findViewById(R.id.TVAttributesWillpowerIN);
		willpowerIN.setText(sheet.getNameBonus(WillpowerBonus.class));

	}
}
